#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
string s;
int Z[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char M[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
int sum = 0;
int ss = 0;
int main()
{
    cin >> n;
    for (int k = 0; k < n; k++)
    {
        cin >> s;
        for (int i = 0; i < 17; i++)
            sum = sum + (s[i] - '0') * Z[i];
        sum = sum % 11;
        if (M[sum] != s[17])
        {
            ss++;
            cout << s << endl;
        }
        sum = 0;
    }
    if (ss == 0)
    {
        cout << "All passed" << endl;
    }
    return 0;
}